package com.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.entity.Users;
import com.mall.mapper.UsersMapper;
import com.mall.service.UsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("UsersService")
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public IPage<Users> findAndCount(Page page) {

        QueryWrapper<Users> queryWrapper = new QueryWrapper<>();

        IPage<Users> data = this.usersMapper.selectPage( page, queryWrapper.orderByAsc( "id") );

        return data;
    }

    @Override
    public Users findOne(QueryWrapper wrapper) {

        Users data = this.usersMapper.selectOne( wrapper );

        return data;
    }

}
